package com.example.erp.utils;

import com.example.erp.config.CommonConfig;
import lombok.Data;

@Data
public class Result {
    private final Integer code;
    private final String msg;
    private final Object data;

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(Object data){
        return new Result(200, null,data);
    }
    public static Result successMsg(String msg){
        return new Result(200, msg,null);
    }
    public static Result successMsg(Object data){
        return new Result(200, CommonConfig.msgTYPE.VIEW.getDescription(),data);
    }
    public static Result successMsg(Object data,String msg){
        return new Result(200, msg,data);
    }

    public static Result upload(Object data){
        return new Result(200,CommonConfig.msgTYPE.UPLOAD.getDescription(),data);
    }
    public static Result error(){
        return new Result(500,CommonConfig.msgTYPE.ERROR.getDescription(),null);
    }

    public static Result error(String msg){
        return new Result(500,msg,null);
    }

    public static Result login(String msg){
        return new Result(401,msg,null);
    }
}
